/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Registros;
import java.sql.SQLException;
import javax.swing.ImageIcon;
import javax.swing.JFormattedTextField;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import utilitarios.conexion;
import javax.swing.text.MaskFormatter;
import java.util.Date;
import java.io.File;
import javax.swing.JFileChooser;
/**
 *
 * @author elearning03
 */
public class registro_funcionario extends javax.swing.JFrame {
    MaskFormatter formatoRUC, formatoCI, formatoTelRes, formatoTelCom, formatoCel,formatoFechaNac;
    int btn_clicado = 0; //variable que almacena cul boton fue clicado
    conexion conecta_funcionario, conecta_ciudad,conecta_direccion, conecta_barrio, conecta_cargo ;// Conexion con BD
    int inicia_cbBuscar =0;//variable que utilizo para buscar en el CB
    String ordenar = "nombre", sexo = "Masculino";//Variable que sera pasada por parametro
    boolean primeraVezCiudad = true, primeraVezBarrio = true,primeraVezDir = true, primeraVezCargo = true;//variables de siempre sera verdadero la primera vez
  
    public registro_funcionario() {
        initComponents();
        conecta_funcionario = new conexion();
        conecta_funcionario.conectar();
        
        conecta_direccion = new conexion();//conecto con direccion
        conecta_direccion.conectar();
        conecta_direccion.executeSQL("select * from casilla_correo order by nombre");
        
        conecta_ciudad = new conexion();//conecto con ciudad
        conecta_ciudad.conectar();
        conecta_ciudad.executeSQL("select * from ciudad order by nombre");
        
        conecta_barrio = new conexion();//conecto con barrio
        conecta_barrio.conectar();
        conecta_barrio.executeSQL("select * from barrio order by nombre");
        
        conecta_cargo = new conexion();//conecto con barrio
        conecta_cargo.conectar();
        conecta_cargo.executeSQL("select * from cargo order by nombre");
        
        conecta_funcionario.executeSQL("select * from funcionario order by codigo");
       
        try
        {
            while(conecta_funcionario.resulset.next())
            {
                cb_buscar.addItem(conecta_funcionario.resulset.getString("nombre"));
            }
            
            while(conecta_direccion.resulset.next())
            {
                cb_item.addItem(conecta_direccion.resulset.getString("nombre"));
            }
           
            while(conecta_barrio.resulset.next())
            {
                cb_barrio.addItem(conecta_barrio.resulset.getString("nombre"));
            }
            
            while(conecta_cargo.resulset.next())
            {
                cb_cargo.addItem(conecta_cargo.resulset.getString("nombre"));
            }
            while(conecta_ciudad.resulset.next())
            {
                cb_ciudad.addItem(conecta_ciudad.resulset.getString("nombre"));
            }
            
            conecta_funcionario.resulset.first();
            tf_codigo.setText(conecta_funcionario.resulset.getString("codigo"));
            tf_nombre.setText(conecta_funcionario.resulset.getString("nombre"));
            tf_direccion.setText(conecta_funcionario.resulset.getString("direccion"));
            tf_numero.setText(conecta_funcionario.resulset.getString("numero"));
            tf_complemento.setText(conecta_funcionario.resulset.getString("complemento"));
            tf_barrio.setText(conecta_funcionario.resulset.getString("barrio"));
            tf_ciudad.setText(conecta_funcionario.resulset.getString("ciudad"));
            tf_ruc.setText(conecta_funcionario.resulset.getString("ruc"));
            tf_cedula.setText(conecta_funcionario.resulset.getString("ci"));
            tf_correo.setText(conecta_funcionario.resulset.getString("cas_correo"));
            tf_residencia.setText(conecta_funcionario.resulset.getString("tel_res"));
            tf_comercial.setText(conecta_funcionario.resulset.getString("tel_com"));
            tf_celular.setText(conecta_funcionario.resulset.getString("celular"));
            tf_email.setText(conecta_funcionario.resulset.getString("email"));
            tf_fechanacimiento.setText(conecta_funcionario.resulset.getString("fch_nac"));
            tf_foto.setText(conecta_funcionario.resulset.getString("foto"));
            ft_fchadmin.setText(conecta_funcionario.resulset.getString("fch_admin"));
            tf_observacion.setText(conecta_funcionario.resulset.getString("observacion"));
            tf_cargo.setText(conecta_funcionario.resulset.getString("cargo"));
            //lb_foto.setIcon(new ImageIcon("/stock/grapic/"+tf_foto.getText()));
            
        }
        catch(SQLException erro)
        {
            JOptionPane.showConfirmDialog(null, "No hay datos que mostrar");
        }
        
        actualizaJtable();// llama el metodo para llenar la tabla
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktopPane1 = new javax.swing.JDesktopPane();
        bg_sexo = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jl_codigo = new javax.swing.JLabel();
        jl_nombre = new javax.swing.JLabel();
        jl_direccion = new javax.swing.JLabel();
        jl_nro = new javax.swing.JLabel();
        jl_complemento = new javax.swing.JLabel();
        jl_barrio = new javax.swing.JLabel();
        jl_ciudad = new javax.swing.JLabel();
        tf_codigo = new javax.swing.JTextField();
        tf_nombre = new javax.swing.JTextField();
        tf_direccion = new javax.swing.JTextField();
        cb_item = new javax.swing.JComboBox();
        tf_numero = new javax.swing.JTextField();
        tf_barrio = new javax.swing.JTextField();
        cb_barrio = new javax.swing.JComboBox();
        tf_ciudad = new javax.swing.JTextField();
        cb_ciudad = new javax.swing.JComboBox();
        tf_complemento = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jl_ruc = new javax.swing.JLabel();
        jl_correo = new javax.swing.JLabel();
        tf_correo = new javax.swing.JTextField();
        jl_ci = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jl_telComercial = new javax.swing.JLabel();
        jl_email = new javax.swing.JLabel();
        jl_telresidencia = new javax.swing.JLabel();
        jl_fechNac = new javax.swing.JLabel();
        jl_celular = new javax.swing.JLabel();
        tf_email = new javax.swing.JTextField();
        try
        {
            formatoFechaNac = new MaskFormatter("####-##-##");
        }
        catch(Exception error)
        {
            JOptionPane.showMessageDialog(null,"No fue posible poner la mascara, error = "+error);
        }
        tf_fechanacimiento = new JFormattedTextField(formatoFechaNac);
        try
        {
            formatoTelRes = new MaskFormatter("###.###.###");
        }
        catch(Exception error)
        {
            JOptionPane.showMessageDialog(null,"No fue posible poner la mascara, error = "+error);
        }
        tf_residencia = new JFormattedTextField(formatoTelRes);
        try
        {
            formatoTelCom = new MaskFormatter("###.###.###");
        }
        catch(Exception error)
        {
            JOptionPane.showMessageDialog(null,"No fue posible poner la mascara, error = "+error);
        }
        tf_comercial = new JFormattedTextField(formatoTelCom);
        try
        {
            formatoCel = new MaskFormatter("###.###.###");
        }
        catch(Exception error)
        {
            JOptionPane.showMessageDialog(null,"No fue posible poner la mascara, error = "+error);
        }
        tf_celular = new JFormattedTextField(formatoCel);
        ft_fchadmin = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jl_foto = new javax.swing.JLabel();
        tf_foto = new javax.swing.JTextField();
        bt_traerFoto = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        tf_observacion = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        tf_cargo = new javax.swing.JTextField();
        cb_cargo = new javax.swing.JComboBox();
        jPanel1 = new javax.swing.JPanel();
        bt_grabar = new javax.swing.JButton();
        bt_modificar = new javax.swing.JButton();
        bt_nuevo = new javax.swing.JButton();
        bt_borrar = new javax.swing.JButton();
        bt_primero = new javax.swing.JButton();
        bt_siguiente = new javax.swing.JButton();
        bt_anterior = new javax.swing.JButton();
        bt_ultimo = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        Tabla = new javax.swing.JTable();
        try
        {
            formatoCI = new MaskFormatter("#.###.###");
        }
        catch(Exception error)
        {
            JOptionPane.showMessageDialog(null,"No fue posible poner la mascara, error = "+error);
        }
        tf_cedula = new JFormattedTextField(formatoCI);

        try
        {
            formatoRUC = new MaskFormatter("#.###.###-##");
        }
        catch(Exception error)
        {
            JOptionPane.showMessageDialog(null,"No fue posible poner la mascara, error = "+error);
        }
        tf_ruc = new JFormattedTextField(formatoRUC);
        jPanel6 = new javax.swing.JPanel();
        tf_buscar = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        cb_buscar = new javax.swing.JComboBox();
        jPanel7 = new javax.swing.JPanel();
        lb_foto = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        rb_femenino = new javax.swing.JRadioButton();
        rb_masculino = new javax.swing.JRadioButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Registro de Cliente");
        setPreferredSize(new java.awt.Dimension(720, 500));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 102, 51));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Registro de Funcionarios");

        jl_codigo.setText("Codigo:");

        jl_nombre.setText("Nombre");

        jl_direccion.setText("Dirección:");

        jl_nro.setText("N°:");

        jl_complemento.setText("Complemento:");

        jl_barrio.setText("Barrio:");

        jl_ciudad.setText("Ciudad:");

        cb_item.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_itemActionPerformed(evt);
            }
        });
        cb_item.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                cb_itemFocusLost(evt);
            }
        });

        cb_barrio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_barrioActionPerformed(evt);
            }
        });
        cb_barrio.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                cb_barrioFocusLost(evt);
            }
        });

        cb_ciudad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_ciudadActionPerformed(evt);
            }
        });
        cb_ciudad.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                cb_ciudadFocusLost(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jl_codigo)
                            .addComponent(jl_barrio))
                        .addGap(14, 14, 14)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tf_codigo)
                            .addComponent(tf_barrio, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jl_nombre)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tf_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 429, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(cb_barrio, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jl_ciudad)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tf_ciudad, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cb_ciudad, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap())))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jl_direccion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tf_direccion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cb_item, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(22, 22, 22)
                        .addComponent(jl_nro)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tf_numero, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jl_complemento)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tf_complemento)
                        .addGap(20, 20, 20))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jl_codigo)
                    .addComponent(tf_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jl_nombre)
                    .addComponent(tf_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jl_direccion)
                    .addComponent(tf_direccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb_item, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jl_nro, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tf_numero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jl_complemento)
                    .addComponent(tf_complemento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jl_barrio)
                    .addComponent(tf_barrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb_barrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jl_ciudad)
                    .addComponent(tf_ciudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb_ciudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(24, 24, 24))
        );

        jl_ruc.setText("RUC:");

        jl_correo.setText("Cas. Correo:");

        jl_ci.setText("C.I");

        jl_telComercial.setText("Tel. Com:");

        jl_email.setText("Email:");

        jl_telresidencia.setText("Tel- Res:");

        jl_fechNac.setText("Fecha Nac:");

        jl_celular.setText("Celular:");

        tf_residencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_residenciaActionPerformed(evt);
            }
        });

        tf_comercial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_comercialActionPerformed(evt);
            }
        });

        jLabel4.setText("Fecha Ingreso:");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jl_telresidencia, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jl_email, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tf_email, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tf_residencia, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jl_fechNac, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jl_telComercial, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tf_fechanacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tf_comercial, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jl_celular, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ft_fchadmin, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tf_celular, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jl_telresidencia)
                    .addComponent(jl_telComercial)
                    .addComponent(jl_celular)
                    .addComponent(tf_residencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tf_comercial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tf_celular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jl_email)
                    .addComponent(tf_email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jl_fechNac)
                    .addComponent(tf_fechanacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ft_fchadmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(5, 5, 5))
        );

        jl_foto.setText("Foto:");

        bt_traerFoto.setText("....");
        bt_traerFoto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_traerFotoActionPerformed(evt);
            }
        });

        jLabel5.setText("Observación:");

        jLabel6.setText("Cargo:");

        tf_cargo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tf_cargoFocusLost(evt);
            }
        });

        cb_cargo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_cargoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jl_foto))
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(tf_observacion, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(tf_foto, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(bt_traerFoto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tf_cargo, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cb_cargo, 0, 214, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(tf_observacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jl_foto)
                            .addComponent(jLabel6)))
                    .addComponent(bt_traerFoto)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tf_foto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tf_cargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cb_cargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(23, 23, 23))
        );

        bt_grabar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/grapic/accept.png"))); // NOI18N
        bt_grabar.setText("Grabar");
        bt_grabar.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        bt_grabar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_grabarActionPerformed(evt);
            }
        });

        bt_modificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/grapic/update-20.png"))); // NOI18N
        bt_modificar.setText("Modificar");
        bt_modificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_modificarActionPerformed(evt);
            }
        });

        bt_nuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/grapic/icon-student.png"))); // NOI18N
        bt_nuevo.setText("Nuevo");
        bt_nuevo.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        bt_nuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_nuevoActionPerformed(evt);
            }
        });

        bt_borrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/grapic/excluded.png"))); // NOI18N
        bt_borrar.setText("Borrar");

        bt_primero.setIcon(new javax.swing.ImageIcon(getClass().getResource("/grapic/control_start_blue.png"))); // NOI18N
        bt_primero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_primeroActionPerformed(evt);
            }
        });

        bt_siguiente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/grapic/control_fastforward_blue.png"))); // NOI18N
        bt_siguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_siguienteActionPerformed(evt);
            }
        });

        bt_anterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/grapic/control_rewind_blue.png"))); // NOI18N
        bt_anterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_anteriorActionPerformed(evt);
            }
        });

        bt_ultimo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/grapic/control_end_blue.png"))); // NOI18N
        bt_ultimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_ultimoActionPerformed(evt);
            }
        });

        Tabla.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Codigo", "Nombre", "Tel. residencia", "Tel. comercial", "Email"
            }
        ));
        Tabla.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jScrollPane2.setViewportView(Tabla);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(bt_primero, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_siguiente, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_anterior, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_ultimo, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(bt_grabar, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_nuevo, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_modificar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_borrar)))
                .addGap(22, 22, 22))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(bt_borrar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(bt_modificar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(bt_nuevo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(bt_primero)
                            .addComponent(bt_siguiente)
                            .addComponent(bt_anterior)
                            .addComponent(bt_ultimo))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(bt_grabar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jl_ruc)
                        .addGap(26, 26, 26)
                        .addComponent(tf_ruc, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(jl_ci)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tf_cedula, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jl_correo)
                        .addGap(18, 18, 18)
                        .addComponent(tf_correo, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 31, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jl_ruc)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jl_ci)
                        .addComponent(tf_correo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jl_correo)
                        .addComponent(tf_cedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(tf_ruc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jLabel2.setText("Buscar:");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(tf_buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addComponent(cb_buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tf_buscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb_buscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel7.setBackground(new java.awt.Color(204, 255, 204));
        jPanel7.setForeground(new java.awt.Color(204, 255, 204));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lb_foto, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(lb_foto, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jPanel8.setBackground(new java.awt.Color(204, 255, 204));

        jLabel3.setText("Sexo");

        bg_sexo.add(rb_femenino);
        rb_femenino.setText("Femenino");
        rb_femenino.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_femeninoActionPerformed(evt);
            }
        });

        bg_sexo.add(rb_masculino);
        rb_masculino.setSelected(true);
        rb_masculino.setText("Masculino");
        rb_masculino.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_masculinoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rb_femenino, javax.swing.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE)
                    .addComponent(rb_masculino, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addComponent(jLabel3)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rb_masculino)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rb_femenino)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jLabel1)
                                        .addGap(106, 106, 106)))
                                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bt_primeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_primeroActionPerformed
        // TODO add your handling code here:
        try
        {
            conecta_funcionario.resulset.first();
            mostrar_datos();
            btn_clicado = 1;
            tf_nombre.setText(conecta_funcionario.resulset.getString("nombre"));
        }
        catch(SQLException erro)
        {
        JOptionPane.showMessageDialog(null, "No es posible mostrar el primer registro "+erro);
        }
    }//GEN-LAST:event_bt_primeroActionPerformed

    private void bt_modificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_modificarActionPerformed
        // Codogo para actualizar la tabla funcionario
                try
        {
           String   sqlUdpt = "UPDATE funcionario SET nombre = '"+ tf_nombre.getText()+"',"+
                  "direccion = "+ tf_direccion.getText()+","+ 
                  "numero = '"+ tf_numero.getText()+"',"+  
                  "complemento = '"+ tf_complemento.getText()+"',"+ 
                  "barrio = "+ tf_barrio.getText()+","+
                  "ciudad = "+ tf_ciudad.getText()+","+
                  "cas_correo = '"+ tf_correo.getText()+"',"+
                  "ci = '"+ tf_cedula.getText()+"',"+
                  "ruc = '"+ tf_ruc.getText()+"',"+
                  "tel_res = '"+ tf_residencia.getText()+"',"+
                  "tel_com = '"+ tf_comercial.getText()+"',"+
                  "celular = '"+ tf_celular.getText()+"',"+
                  "email = '"+ tf_email.getText()+"',"+
                  "fch_nac = '"+ tf_fechanacimiento.getText()+"',"+ 
                  "foto = '"+ tf_foto.getText()+"',"+ 
                  "sexo = '"+sexo+"',"+ 
                   "fch_admin = '"+ ft_fchadmin.getText()+"' ,"+ 
                   "observacion = '"+ tf_observacion.getText()+"',"+ 
                   "cargo = '"+ tf_cargo.getText()+
                   "' where codigo = "+tf_codigo.getText();
                  JOptionPane.showMessageDialog(null, sqlUdpt);
                  conecta_funcionario.statement.executeUpdate(sqlUdpt);
                   JOptionPane.showMessageDialog(null, "Modificción realizada con exito");
                   conecta_funcionario.resulset = conecta_funcionario.statement.executeQuery("select * from funcionario order by codigo");
                   conecta_funcionario.resulset.next();
                   mostrar_datos();     
        }
      
       catch (SQLException e)
         {
              
             JOptionPane.showMessageDialog(null, "Error al intentar actualizar los datos "+e);
         }
       
    }//GEN-LAST:event_bt_modificarActionPerformed

    private void bt_siguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_siguienteActionPerformed
        // TODO add your handling code here:
        try
        {
         conecta_funcionario.resulset.next();
         mostrar_datos();
         btn_clicado = 2;
                      
        }
        catch (SQLException erro)
           {
                JOptionPane.showMessageDialog(null,"No es posible mostrar el siguiente registro "+erro);
           }
    }//GEN-LAST:event_bt_siguienteActionPerformed

    private void bt_anteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_anteriorActionPerformed
        // TODO add your handling code here:
        try
        {
            conecta_funcionario.resulset.previous();
            mostrar_datos();
            btn_clicado = 3;
                     
        }
        catch (SQLException erro)
           {
                JOptionPane.showMessageDialog(null,"No es posible mostrar el registro anterior "+erro);
           }
    }//GEN-LAST:event_bt_anteriorActionPerformed

    private void bt_ultimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_ultimoActionPerformed
        // TODO add your handling code here:
        try
        {
            conecta_funcionario.resulset.last();
            mostrar_datos();
            btn_clicado = 4;
                       
        }
        catch (SQLException erro)
           {
                JOptionPane.showMessageDialog(null,"No es posible mostrar el último registro "+erro);
           }
    }//GEN-LAST:event_bt_ultimoActionPerformed

    private void bt_nuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_nuevoActionPerformed
        // TODO add your handling code here:
        try
      {
           conecta_funcionario.resulset.last();
           int cod = conecta_funcionario.resulset.getInt("codigo")+1;
           tf_codigo.setText("");
           tf_nombre.setText("");
           tf_direccion.setText("");
           tf_numero.setText("");
           tf_complemento.setText("");
           tf_barrio.setText("");
           tf_ciudad.setText("");
           tf_correo.setText("");
           tf_cedula.setText("");
           tf_ruc.setText("");
           tf_residencia.setText("");
           tf_comercial.setText("");
           tf_celular.setText("");
           tf_email.setText("");
           ft_fchadmin.setText("");
           tf_observacion.setText("");
           tf_cargo.setText("");
           
           //Voy a cambiar fecha de nacimiento por fecha de registro, con esto asigno la fecha actual
           //tf_fechanacimiento.setText("");
           Date fecha = new Date();
           String anho = ""+(1900 + fecha.getYear());
           String mes = ""+ String.valueOf(fecha.getMonth()+1);
           String dia = ""+ fecha.getDate();
           if (Integer.parseInt(mes)<= 9)
           {
              mes = "0"+mes; 
           }
           
           tf_fechanacimiento.setText(anho+mes+dia);
           //***********************************
           
           tf_foto.setText("Sin foto.jpg");
           lb_foto.setIcon(new ImageIcon("C:\\Proyectos\\stock\\stock\\src\\grapic\\"+tf_foto.getText()));
           //cb_dpto.setSelectedItem("");
           //cb_dpto.setSelectedItem("Concepción");
           tf_nombre.requestFocus();
           tf_codigo.setEditable(false);
           tf_codigo.setText(cod+"");
      }
      catch (SQLException e)
      {
        JOptionPane.showMessageDialog(null,"No es posible crear un nuevo registro  "+e);
      }
    }//GEN-LAST:event_bt_nuevoActionPerformed

    private void bt_grabarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_grabarActionPerformed
        // TODO add your handling code here:
        try
        {
           String sqlInsert = "insert into funcionario (codigo,nombre,direccion,numero,complemento,barrio,ciudad,cas_correo,ci,ruc,tel_res,tel_com,celular,email,fch_nac,foto,sexo,fch_admin,observacion,cargo)"
                   + " values ("+
					tf_codigo.getText()+",'"+  
					tf_nombre.getText()+"',"+
					tf_direccion.getText()+",'"+ 
					tf_numero.getText()+"','"+  
					tf_complemento.getText()+"',"+ 
					tf_barrio.getText()+","+
					tf_ciudad.getText()+",'"+
                                        tf_correo.getText()+"','"+
                                        tf_cedula.getText()+"','"+
                                        tf_ruc.getText()+"','"+
                                        tf_residencia.getText()+"','"+
					tf_comercial.getText()+"','"+
					tf_celular.getText()+"','"+
					tf_email.getText()+"','"+
					tf_fechanacimiento.getText()+"','"+ 
					tf_foto.getText()+"','"+ 
					sexo+"','"+
                                       ft_fchadmin.getText()+"','"+ 
                                       tf_observacion.getText()+"','"+ 
                                       tf_cargo.getText()+"')";	   
		   
           JOptionPane.showMessageDialog(null,"sqlInsert "+ sqlInsert);	   
                   conecta_funcionario.statement.executeUpdate(sqlInsert);
                   JOptionPane.showMessageDialog(null, "Grabacion realizada con exito");
       //Actualizo el resulset
                conecta_funcionario.resulset= conecta_funcionario.statement.executeQuery("select * from funcionario order by codigo");
                //actualiza_cb_ciudad();
                conecta_funcionario.resulset.first();
                mostrar_datos();
        }
        catch (SQLException e)
        {
         
         JOptionPane.showMessageDialog(null,"Error al intentar grabar el registro  "+e);
        }
    }//GEN-LAST:event_bt_grabarActionPerformed

    private void tf_residenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_residenciaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tf_residenciaActionPerformed

    private void tf_comercialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_comercialActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tf_comercialActionPerformed

    private void cb_ciudadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_ciudadActionPerformed
        // Proceso para actualizar el codigo de la ciudad
        if(primeraVezCiudad == false)
        {
            try
            {
                String sql = "select * from ciudad Where nombre like '"+cb_ciudad.getSelectedItem()+"'";
                conecta_ciudad.executeSQL(sql);
                conecta_ciudad.resulset.first();
                tf_ciudad.setText(conecta_ciudad.resulset.getString("codigo"));
            }
            catch(SQLException e)
            {
                JOptionPane.showMessageDialog(null,"Error al intentar insertar el codigo de la ciudad  "+e);
            }
        
        }
           primeraVezCiudad = false;
        
    }//GEN-LAST:event_cb_ciudadActionPerformed

    private void cb_itemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_itemActionPerformed
        // TODO add your handling code here:
        if(primeraVezDir == false)
            {
            try
               {
                String sql = "select * from casilla_correo Where nombre like '"+cb_item.getSelectedItem()+"'";
                conecta_direccion.executeSQL(sql);
                conecta_direccion.resulset.first();
                tf_direccion.setText(conecta_direccion.resulset.getString("codigo"));
                }
            catch(SQLException e)
                {
                JOptionPane.showMessageDialog(null,"Error, no es posibe encotrar el barrio  "+e);
                
                }
            }
        primeraVezDir = false;
        
    }//GEN-LAST:event_cb_itemActionPerformed

    private void cb_barrioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_barrioActionPerformed
        // TODO add your handling code here:
        if(primeraVezBarrio == false)
        {
            try
            {
                String sql = "select * from barrio Where nombre like '"+cb_barrio.getSelectedItem()+"'";
                conecta_barrio.executeSQL(sql);
                conecta_barrio.resulset.first();
                tf_barrio.setText(conecta_barrio.resulset.getString("codigo"));
            }
            catch(SQLException e)
            {
                JOptionPane.showMessageDialog(null,"Error, no es posible encontrar el barrio  "+e);
                tf_barrio.requestFocus();
            }
         }
           primeraVezBarrio = false;
    }//GEN-LAST:event_cb_barrioActionPerformed

    private void rb_masculinoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_masculinoActionPerformed
        // TODO add your handling code here:
        sexo = "M";
    }//GEN-LAST:event_rb_masculinoActionPerformed

    private void rb_femeninoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_femeninoActionPerformed
        // TODO add your handling code here:
        sexo = "F";
    }//GEN-LAST:event_rb_femeninoActionPerformed

    private void bt_traerFotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_traerFotoActionPerformed
        // TODO add your handling code here:
        try
        {
            JFileChooser busca_foto = new JFileChooser();//inicializo la variable
            busca_foto.setCurrentDirectory(new File("C:\\Proyectos\\stock\\ stock\\src\\grapic\\"));//seteo donde tiene que ir a buscar el archivo
            busca_foto.setDialogTitle("Cargar la imagen del funcionario");//seteo el titulo
            busca_foto.showOpenDialog(this);//
            String foto = ""+busca_foto.getSelectedFile().getName();//trae y asigna el nombre del archivo seleccionado
            tf_foto.setText(foto);//asigno el nombre de la foto dentro del textField
            lb_foto.setIcon(new ImageIcon("C:\\Proyectos\\stock\\ stock\\src\\grapic\\"+tf_foto.getText()));//actualizo la imagen
        
        }
        catch (Exception e)
         {
                JOptionPane.showMessageDialog(null,"No fue posible cargar la foto."+ e);
         }
        
    }//GEN-LAST:event_bt_traerFotoActionPerformed

    private void cb_cargoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_cargoActionPerformed
        // Procedimiento para actualizar el codigo del cargo
        if(primeraVezCargo == false)
        {
            try
            {
                String sql = "select * from cargo Where nombre like '"+cb_cargo.getSelectedItem()+"'";
                conecta_cargo.executeSQL(sql);
                conecta_cargo.resulset.first();
                tf_cargo.setText(conecta_cargo.resulset.getString("codigo"));
            }
            catch(SQLException e)
            {
                JOptionPane.showMessageDialog(null,"Error, no es posible encontrar el barrio  "+e);
                tf_cargo.requestFocus();
            }
         }
           primeraVezCargo = false;
    }//GEN-LAST:event_cb_cargoActionPerformed

    private void tf_cargoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tf_cargoFocusLost
        // TODO add your handling code here:
        actualizaComboBoxCargo();
    }//GEN-LAST:event_tf_cargoFocusLost

    private void cb_barrioFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cb_barrioFocusLost
        // TODO add your handling code here:
        actualizaComboBoxBarrio();
    }//GEN-LAST:event_cb_barrioFocusLost

    private void cb_itemFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cb_itemFocusLost
        // TODO add your handling code here:
        actualizaComboBoxDir();
    }//GEN-LAST:event_cb_itemFocusLost

    private void cb_ciudadFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cb_ciudadFocusLost
        // TODO add your handling code here:
        actualizaComboBoxCiudad();
    }//GEN-LAST:event_cb_ciudadFocusLost

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(registro_funcionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(registro_funcionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(registro_funcionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(registro_funcionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new registro_funcionario().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable Tabla;
    private javax.swing.ButtonGroup bg_sexo;
    private javax.swing.JButton bt_anterior;
    private javax.swing.JButton bt_borrar;
    private javax.swing.JButton bt_grabar;
    private javax.swing.JButton bt_modificar;
    private javax.swing.JButton bt_nuevo;
    private javax.swing.JButton bt_primero;
    private javax.swing.JButton bt_siguiente;
    private javax.swing.JButton bt_traerFoto;
    private javax.swing.JButton bt_ultimo;
    private javax.swing.JComboBox cb_barrio;
    private javax.swing.JComboBox cb_buscar;
    private javax.swing.JComboBox cb_cargo;
    private javax.swing.JComboBox cb_ciudad;
    private javax.swing.JComboBox cb_item;
    private javax.swing.JFormattedTextField ft_fchadmin;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel jl_barrio;
    private javax.swing.JLabel jl_celular;
    private javax.swing.JLabel jl_ci;
    private javax.swing.JLabel jl_ciudad;
    private javax.swing.JLabel jl_codigo;
    private javax.swing.JLabel jl_complemento;
    private javax.swing.JLabel jl_correo;
    private javax.swing.JLabel jl_direccion;
    private javax.swing.JLabel jl_email;
    private javax.swing.JLabel jl_fechNac;
    private javax.swing.JLabel jl_foto;
    private javax.swing.JLabel jl_nombre;
    private javax.swing.JLabel jl_nro;
    private javax.swing.JLabel jl_ruc;
    private javax.swing.JLabel jl_telComercial;
    private javax.swing.JLabel jl_telresidencia;
    private javax.swing.JLabel lb_foto;
    private javax.swing.JRadioButton rb_femenino;
    private javax.swing.JRadioButton rb_masculino;
    private javax.swing.JTextField tf_barrio;
    private javax.swing.JTextField tf_buscar;
    private javax.swing.JTextField tf_cargo;
    private javax.swing.JFormattedTextField tf_cedula;
    private javax.swing.JFormattedTextField tf_celular;
    private javax.swing.JTextField tf_ciudad;
    private javax.swing.JTextField tf_codigo;
    private javax.swing.JFormattedTextField tf_comercial;
    private javax.swing.JTextField tf_complemento;
    private javax.swing.JTextField tf_correo;
    private javax.swing.JTextField tf_direccion;
    private javax.swing.JTextField tf_email;
    private javax.swing.JFormattedTextField tf_fechanacimiento;
    private javax.swing.JTextField tf_foto;
    private javax.swing.JTextField tf_nombre;
    private javax.swing.JTextField tf_numero;
    private javax.swing.JTextField tf_observacion;
    private javax.swing.JFormattedTextField tf_residencia;
    private javax.swing.JFormattedTextField tf_ruc;
    // End of variables declaration//GEN-END:variables

public void mostrar_datos()
 {
    try
    {
    tf_codigo.setText(conecta_funcionario.resulset.getString("codigo"));
    tf_nombre.setText(conecta_funcionario.resulset.getString("nombre"));
    tf_direccion.setText(conecta_funcionario.resulset.getString("direccion"));
    tf_numero.setText(conecta_funcionario.resulset.getString("numero"));
    tf_complemento.setText(conecta_funcionario.resulset.getString("complemento"));
    tf_barrio.setText(conecta_funcionario.resulset.getString("barrio"));
    tf_ciudad.setText(conecta_funcionario.resulset.getString("ciudad"));
    tf_ruc.setText(conecta_funcionario.resulset.getString("ruc"));
    tf_cedula.setText(conecta_funcionario.resulset.getString("ci"));
    tf_correo.setText(conecta_funcionario.resulset.getString("cas_correo"));
    tf_residencia.setText(conecta_funcionario.resulset.getString("tel_res"));
    tf_comercial.setText(conecta_funcionario.resulset.getString("tel_com"));
    tf_celular.setText(conecta_funcionario.resulset.getString("celular"));
    tf_email.setText(conecta_funcionario.resulset.getString("email"));
    tf_fechanacimiento.setText(conecta_funcionario.resulset.getString("fch_nac"));
    tf_foto.setText(conecta_funcionario.resulset.getString("foto"));
    lb_foto.setIcon(new ImageIcon("/stock/grapic/"+tf_foto.getText()));
    ft_fchadmin.setText(conecta_funcionario.resulset.getString("fch_admin"));
    tf_observacion.setText(conecta_funcionario.resulset.getString("observacion"));
    tf_cargo.setText(conecta_funcionario.resulset.getString("cargo"));
    //actualizar combo box
    actualizaComboBoxBarrio();
    actualizaComboBoxDir();
    actualizaComboBoxCiudad();
    actualizaComboBoxCargo();
    //Actualizar Radio Button
    if(conecta_funcionario.resulset.getString("sexo").equals("M"))
       {
        rb_masculino.setSelected(true);
       }
    else
       {
        rb_femenino.setSelected(true);
       }
    
    }
    catch(SQLException erro)
    {
     if(btn_clicado == 1)
               {
                   JOptionPane.showMessageDialog(null, "Usted ya esta en el primer registro");
               }
               else if (btn_clicado == 4)
               {
                JOptionPane.showMessageDialog(null, "Usted ya esta en el último registro");
               }
               else
                 
                JOptionPane.showMessageDialog(null,"No hay datos "+erro);
               btn_clicado = 0;
           }
    }
public void actualizaJtable()
{
    Tabla.getColumnModel().getColumn(0).setPreferredWidth(20);//defino el largo de la columna
    Tabla.getColumnModel().getColumn(1).setPreferredWidth(150);
    Tabla.getColumnModel().getColumn(2).setPreferredWidth(20);
    Tabla.getColumnModel().getColumn(3).setPreferredWidth(20);
    Tabla.getColumnModel().getColumn(4).setPreferredWidth(20);
     
//conecta_funcionario.executeSQL("select * from funcionario where nombre like '"+tf_buscar.getText()+"%' order by" +ordenacion);

    DefaultTableModel modelo = (DefaultTableModel)Tabla.getModel();
    modelo.setNumRows(0);//siempre que sea llamado el metodo limpiara la tabla

    try
  {
      while( conecta_funcionario.resulset.next())
          //creo un vector donde cada una de las columnas tiene que estar conectada a un capo de la BD
          modelo.addRow(new Object[]{ conecta_funcionario.resulset.getString("codigo"),conecta_funcionario.resulset.getString("nombre"),conecta_funcionario.resulset.getString("tel_res"),conecta_funcionario.resulset.getString("tel_com"),conecta_funcionario.resulset.getString("email")});
           conecta_funcionario.resulset.first();
  }
catch(SQLException error)
        {
        JOptionPane.showMessageDialog(null, "Error al listar los datos");
        }

}

public void actualizaComboBoxCiudad()
{
try
            {
                String sql = "select * from ciudad Where codigo ="+tf_ciudad.getText();
                conecta_ciudad.executeSQL(sql);
                conecta_ciudad.resulset.first();
                cb_ciudad.setSelectedItem(conecta_ciudad.resulset.getString("nombre"));
            }
            catch(SQLException e)
                {
                JOptionPane.showMessageDialog(null,"Error al intentar insertar el codigo de la ciudad  "+e);
                tf_ciudad.requestFocus();
                }
          
}
public void actualizaComboBoxDir()
{
    try
       {
                String sql = "select * from casilla_correo Where codigo ="+tf_direccion.getText();
                conecta_direccion.executeSQL(sql);
                conecta_direccion.resulset.first();
                cb_item.setSelectedItem(conecta_direccion.resulset.getString("nombre"));
         }
            catch(SQLException e)
                {
                JOptionPane.showMessageDialog(null,"Error, no es posibe encotrar el barrio  "+e);
                tf_direccion.requestFocus();
                }
            }
      

public void actualizaComboBoxBarrio()
{
    try
       {
       String sql = "select * from barrio Where codigo ="+tf_barrio.getText();
                conecta_barrio.executeSQL(sql);
                conecta_barrio.resulset.first();
                cb_barrio.setSelectedItem(conecta_barrio.resulset.getString("nombre"));
         }
            catch(SQLException e)
                {
                JOptionPane.showMessageDialog(null,"Error, no es posibe encotrar el barrio  "+e);
                tf_barrio.requestFocus();
                }
            }
public void actualizaComboBoxCargo()
{
    try
       {
       String sql = "select * from cargo Where codigo ="+tf_cargo.getText();
                conecta_cargo.executeSQL(sql);
                conecta_cargo.resulset.first();
                cb_cargo.setSelectedItem(conecta_cargo.resulset.getString("nombre"));
         }
            catch(SQLException e)
                {
                JOptionPane.showMessageDialog(null,"Error, no es posibe encotrar el cargo "+e);
                tf_cargo.requestFocus();
                }
    }

}


